<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () {
//	phpinfo();
//});

Route::get('/','Index\IndexController@index')->name('index.index');

Route::get('/wl',function (){
	$user = session('wechat.oauth_user.default');
	dd($user);
})->middleware(['wechat.oauth'])->name('index.index');

//php artisan make:controller Admin/UserController --resource
//Route::resource('index','IndexController');

Route::namespace('Index')->prefix('index')->middleware('throttle:20')->group(function (){

	//抽奖
	Route::prefix('prize')->group(function (){
		Route::get('getPrize','PrizeController@getPrize')->name('index.prize.getPrize');
	});

	//易语言小工具请求连接 与本商城无关路由
	Route::prefix('index')->group(function (){
		Route::get('getBaiduDownMenu','IndexController@getBaiduDownMenu');
	});

	Route::prefix('index')->group(function (){
		Route::get('duguVedioUpdate','IndexController@duguVedioUpdate');
	});

	//订单支付
	Route::prefix('order')->group(function(){
		//订单支付首页
		Route::get('pay','OrderController@pay')->name('index.order.pay');
		//订单支付前端同步回调页面
		Route::get('pay_return','OrderController@pay_return')->name('index.order.pay_return');

	});

	//登录
	Route::prefix('login')->group(function (){
		//登录页面
		Route::get('login','LoginController@login')->name('index.login.login');
		//微信登录
		Route::get('wxLogin','LoginController@wxLogin')->name('index.login.wxLogin')->middleware(['wechat.oauth']);

	});


});

Route::get('getShareSign','Api\WechatController@getShareSign')->name('index.login.getShareSign')->middleware(['wechat.oauth']);

//后台登录
Route::get('/admin/login','Admin\LoginController@showLoginForm')->name('admin.login');
Route::post('/admin/login','Admin\LoginController@login');

//后台路由
Route::namespace('Admin')->middleware(['admin.auth','auth:admin'])->prefix('admin')->group(function (){

	//退出
	Route::get('/login/logout','LoginController@logout')->name('admin.logout');

	//后台统一带admin访问
	Route::prefix('index')->group(function (){
		//后台首页
		Route::get('index','IndexController@index')->name('admin.index.index');
	});

	//文章分类
	Route::prefix('category')->group(function (){
		//列表
		Route::get('index','CategoryController@index')->name('admin.category.index');
		//创建
		Route::get('create','CategoryController@create')->name('admin.category.create');
		Route::post('store','CategoryController@store')->name('admin.category.store');
		//编辑
		Route::get('edit/{id}','CategoryController@edit')->name('admin.category.edit');
		Route::post('update/{id}','CategoryController@update')->name('admin.category.update');
		//软删除
		Route::get('destroy/{id}','CategoryController@destroy')->name('admin.category.destroy');
		//物理删除
		Route::get('forceDelete/{id}','CategoryController@forceDelete')->name('admin.category.forceDelete');
	});

	//文章管理
	Route::prefix('article')->group(function (){
		//列表
		Route::get('index','ArticleController@index')->name('admin.article.index');
		//创建
		Route::get('create','ArticleController@create')->name('admin.article.create');
		Route::post('store','ArticleController@store')->name('admin.article.store');
		//编辑
		Route::get('edit/{id}','ArticleController@edit')->name('admin.article.edit');
		Route::post('update/{id}','ArticleController@update')->name('admin.article.update');
		//软删除
		Route::get('destroy/{id}','ArticleController@destroy')->name('admin.article.destroy');
		//物理删除
		Route::get('forceDelete/{id}','ArticleController@forceDelete')->name('admin.article.forceDelete');
	});

	//用户
	Route::prefix('user')->group(function (){
		//列表
		Route::get('index','UserController@index')->name('admin.user.index');
		//发送邮件
		Route::get('sendEmail','UserController@sendEmail')->name('admin.user.sendEmail');
		//编辑用户
		Route::get('edit/{id}','UserController@edit')->name('admin.user.edit');
		Route::get('destroy/{id}','UserController@destroy')->name('admin.user.destroy');

		//ajax改变用户状态
		Route::post('ajaxChangeUserStatus','UserController@ajaxChangeUserStatus')->name('admin.user.ajaxChangeUserStatus');
	});

	//配置管理
	Route::get('web_config/index','WebConfig@index')->name('admin.web_config.index');
	Route::post('web_config/store','WebConfig@store')->name('admin.web_config.store');

	//管理员管理
	Route::prefix('admin')->group(function (){
		//列表
		Route::get('index','AdminController@index')->name('admin.admin.index');
		Route::get('login_log','AdminController@login_log')->name('admin.admin.login_log');
		//新增
		Route::get('create','AdminController@create')->name('admin.admin.create');
		Route::post('store','AdminController@store')->name('admin.admin.store');
		//修改
		Route::get('edit/{id}','AdminController@edit')->name('admin.admin.edit');
		Route::post('update/{id}','AdminController@update')->name('admin.admin.update');
		//删除
		Route::get('destroy/{id}','AdminController@destroy')->name('admin.admin.destroy');
	});

	//角色
	Route::prefix('role')->group(function (){
		//列表
		Route::get('index','RoleController@index')->name('admin.role.index');
		//创建
		Route::get('create','RoleController@create')->name('admin.role.create');
		Route::post('store','RoleController@store')->name('admin.role.store');
		//修改
		Route::get('edit/{id}','RoleController@edit')->name('admin.role.edit');
		Route::post('update/{id}','RoleController@update')->name('admin.role.update');
		//删除
		Route::get('destroy/{id}','RoleController@destroy')->name('admin.role.destroy');

		//分配权限
		Route::get('editPermission/{id}','RoleController@editPermission')->name('admin.role.editPermission');
		Route::post('updatePermission/{id}','RoleController@updatePermission')->name('admin.role.updatePermission');
	});

	//权限
	Route::prefix('permission')->group(function (){
		//列表
		Route::get('index','PermissionController@index')->name('admin.permission.index');
		//创建
		Route::get('create','PermissionController@create')->name('admin.permission.create');
		Route::post('store','PermissionController@store')->name('admin.permission.store');
		//修改
		Route::get('edit/{id}','PermissionController@edit')->name('admin.permission.edit');
		Route::post('update/{id}','PermissionController@update')->name('admin.permission.update');
		//删除
		Route::get('destroy/{id}','PermissionController@destroy')->name('admin.permission.destroy');
	});

	//商品品牌
	Route::prefix('goods_brand')->group(function (){
		//列表
		Route::get('index','GoodsBrandController@index')->name('admin.goods_brand.index');
		//添加
		Route::get('create','GoodsBrandController@create')->name('admin.goods_brand.create');
		Route::post('store','GoodsBrandController@store')->name('admin.goods_brand.store');
		//修改
		Route::get('edit/{id}','GoodsBrandController@edit')->name('admin.goods_brand.edit');
		Route::post('update/{id}','GoodsBrandController@update')->name('admin.goods_brand.update');
		//删除
		Route::get('destroy/{id}','GoodsBrandController@destroy')->name('admin.goods_brand.destroy');
	});

	//文章分类
	Route::prefix('goods_category')->group(function (){
		//列表
		Route::get('index','GoodsCategoryController@index')->name('admin.goods_category.index');
		//创建
		Route::get('create','GoodsCategoryController@create')->name('admin.goods_category.create');
		Route::post('store','GoodsCategoryController@store')->name('admin.goods_category.store');
		//编辑
		Route::get('edit/{id}','GoodsCategoryController@edit')->name('admin.goods_category.edit');
		Route::post('update/{id}','GoodsCategoryController@update')->name('admin.goods_category.update');
		//软删除
		Route::get('destroy/{id}','GoodsCategoryController@destroy')->name('admin.goods_category.destroy');
		//物理删除
		Route::get('forceDelete/{id}','GoodsCategoryController@forceDelete')->name('admin.goods_category.forceDelete');
	});


	//商品类型
	Route::prefix('goods_type')->group(function (){
		//列表
		Route::get('index','GoodsTypeController@index')->name('admin.goods_type.index');
		//添加
		Route::get('create','GoodsTypeController@create')->name('admin.goods_type.create');
		Route::post('store','GoodsTypeController@store')->name('admin.goods_type.store');
		//修改
		Route::get('edit/{id}','GoodsTypeController@edit')->name('admin.goods_type.edit');
		Route::post('update/{id}','GoodsTypeController@update')->name('admin.goods_type.update');
		//删除
		Route::get('destroy/{id}','GoodsTypeController@destroy')->name('admin.goods_type.destroy');
	});

	//规格
	Route::prefix('spec')->group(function (){
		//列表
		Route::get('index/{id}','SpecController@index')->name('admin.spec.index');
		//添加
		Route::get('create','SpecController@create')->name('admin.spec.create');
		Route::post('store','SpecController@store')->name('admin.spec.store');
		//修改
		Route::get('edit/{id}','SpecController@edit')->name('admin.spec.edit');
		Route::post('update/{id}','SpecController@update')->name('admin.spec.update');
		//删除
		Route::get('destroy/{id}','SpecController@destroy')->name('admin.spec.destroy');
	});

	//规格属性值
	Route::prefix('spec_vlaue')->group(function (){
		//列表
		Route::get('index/{sped_id}','SpecValueController@index')->name('admin.spec_value.index');
		//添加
		Route::get('create','SpecValueController@create')->name('admin.spec_value.create');
		Route::post('store/{spec_id}','SpecValueController@store')->name('admin.spec_value.store');
		//修改
		Route::get('edit/{id}','SpecValueController@edit')->name('admin.spec_value.edit');
		Route::post('update/{id}','SpecValueController@update')->name('admin.spec_value.update');
		//删除
		Route::get('destroy/{id}','SpecValueController@destroy')->name('admin.spec_value.destroy');
	});

	//商品
	Route::prefix('goods')->group(function (){
		Route::get('index','GoodsController@index')->name('admin.goods.index');
		//添加
		Route::get('create','GoodsController@create')->name('admin.goods.create');
		Route::post('store','GoodsController@store')->name('admin.goods.store');
		//添加商品时，ajax获取规格
		Route::get('ajaxGetSpec','GoodsController@ajaxGetSpec')->name('admin.goods.ajaxGetSpec');
		//获取库存的笛卡尔积数据结构
		Route::post('ajaxGetStockDicar','GoodsController@ajaxGetStockDicar')->name('admin.goods.ajaxGetStockDicar');
		//编辑
		Route::get('edit/{id}','GoodsController@edit')->name('admin.goods.edit');
		//编辑时，获取最新的库存到修改后的dom中
		Route::get('ajaxGetNowInventory','GoodsController@ajaxGetNowInventory')->name('admin.goods.ajaxGetNowInventory');
		//编辑时删除相册图片
		Route::get('ajaxDeleteImage','GoodsController@ajaxDeleteImage')->name('admin.goods.ajaxDeleteImage');
		Route::post('update/{id}','GoodsController@update')->name('admin.goods.update');
		//销毁
		Route::get('destroy','GoodsController@destroy')->name('admin.goods.destroy');
		//商品加入秒杀
		Route::get('addToSecKill','GoodsController@addToSecKill')->name('admin.goods.addToSecKill');
		//秒杀商品添加动作
		Route::post('addSeckillGoods','GoodsController@addSeckillGoods')->name('admin.goods.addSeckillGoods');

	});

	//订单列表
	Route::prefix('order')->group(function (){
		//列表
		Route::get('index','OrderController@index')->name('admin.order.index');
		//订单详情
		Route::get('detail/{id}','OrderController@detail')->name('admin.order.detail');
		//取消订单
		Route::get('destroy','OrderController@destroy')->name('admin.order.destroy');
	});

	//秒杀
	Route::prefix('sec_kill')->group(function (){
	    //秒杀商品列表
	    Route::get('index','SecKillController@index')->name('admin.sec_kill.index');
	    //ajax改变状态
	    Route::post('ajaxChangeStatus','SecKillController@ajaxChangeStatus')->name('admin.sec_kill.ajaxChangeStatus');
	    //删除秒杀商品
	    Route::get('destroy','SecKillController@destroy')->name('admin.sec_kill.destroy');
    });
});

Route::get('/ws', function () {
    // 响应状态码200的任意内容
    return 'websocket';
})->middleware(['auth']);
